package com.ruoyi.active.controller;

import java.util.List;
import java.io.IOException;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

//import com.ruoyi.active.api.domain.CfDrawal;
//import com.ruoyi.active.api.domain.CfOrder;
import com.ruoyi.active.api.domain.CfDrawal;
import com.ruoyi.active.api.domain.CfOrder;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.DigestUtils;
//import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.active.domain.CfShop;
import com.ruoyi.active.service.ICfShopService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商户管理Controller
 * 
 * @author zhangbiao
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/shop")
public class CfShopController extends BaseController
{
    @Autowired
    private ICfShopService cfShopService;

    /**
     * 查询商户管理列表
     */
//    @RequiresPermissions("active:shop:list")
    @GetMapping("/list")
    public TableDataInfo list(CfShop cfShop)
    {
        startPage();
        List<CfShop> list = cfShopService.selectCfShopList(cfShop);
        return getDataTable(list);
    }

    /**
     * 导出商户管理列表
     */
    @RequiresPermissions("active:shop:export")
    @Log(title = "商户管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CfShop cfShop)
    {
        List<CfShop> list = cfShopService.selectCfShopList(cfShop);
        ExcelUtil<CfShop> util = new ExcelUtil<CfShop>(CfShop.class);
        util.exportExcel(response, list, "商户管理数据");
    }

    /**
     * 获取商户管理详细信息
     */
//    @RequiresPermissions("active:shop:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cfShopService.selectCfShopById(id));
    }

    /**
     * 新增商户管理
     */
//    @RequiresPermissions("active:shop:add")
    @Log(title = "商户管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfShop cfShop)
    {
        return toAjax(cfShopService.insertCfShop(cfShop));
    }

    @Log(title = "商户管理", businessType = BusinessType.INSERT)
    @PostMapping("/shopRegister")
    public AjaxResult shopRegister(@RequestBody CfShop cfShop)
    {
        return toAjax(cfShopService.shopRegister(cfShop));
    }

    @PostMapping("/shopLogin")
    public AjaxResult shopLogin(@RequestBody CfShop cfShop)
    {
        return success(cfShopService.shopLogin(cfShop));
    }

    /**
     * 修改商户管理
     */
//    @RequiresPermissions("active:shop:edit")
    @Log(title = "商户管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfShop cfShop)
    {
        return toAjax(cfShopService.updateCfShop(cfShop));
    }

    @Log(title = "核销订单", businessType = BusinessType.UPDATE)
    @PutMapping("/verification")
    public AjaxResult hexiao(@RequestBody CfOrder cfOrder)
    {
        return toAjax(cfShopService.hexiao(cfOrder));
    }

    @Log(title = "提现", businessType = BusinessType.UPDATE)
    @PostMapping("/drawal")
    public AjaxResult drawal(@RequestBody CfDrawal cfDrawal) {
        return toAjax(cfShopService.tixian(cfDrawal));
    }
    /**
     * 删除商户管理
     */
    @RequiresPermissions("active:shop:remove")
    @Log(title = "商户管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cfShopService.deleteCfShopByIds(ids));
    }


}
